<template>
    <div>
        <tabbar></tabbar>

        <div class="content">
            <div class="search">
                <h3>全国失散人口数据库</h3>
                <van-divider :style="{ color: '#1989fa', borderColor: '#1989fa', padding: '0 16px' }">
                寻人找人·家寻亲人·亲人寻家·寻老友/战友·寻亲·感恩寻人·登记寻人启事·各地寻人团帮找
                </van-divider>

                <div class="msgBox">
                    <div class="msg">
                        <p>响应「非法言论·净网2020」专项行动！请广大寻找亲人的朋友们遵守相关法律法规，不要发布虚假信息，积极举报违法违规内容。</p>
                        <p>请遵守希望寻人网公约言论规则，不得违反国家法律法规！</p>
                        <p>树立网络安全关，争当中国好网民！</p>
                    </div>
                    <div class="vsearch">
                         <!-- @search="onSearch" -->
                         <!-- v-model="value" -->
                        <van-search
                        show-action
                        placeholder="请输入被寻人姓名"
                        label=""
                        v-model="personName"
                        @keyup.enter="onSearch"
                        >
                        <template #action>
                            <!-- @click="onSearch" -->
                            <div @click="onSearch" >搜索</div>
                        </template>
                        </van-search>
                    </div>
                </div>
                
            </div>

            <FindList :findData="this.findData"/>

            <div class="myFind">
                <h2>只为找到你</h2>
                <div class="findBtn" @click="tofind">
                    我要寻人
                </div>
            </div>
        </div>

        <end></end>
    </div>
</template>
<script>
import Vue from 'vue';
import {Divider,Search} from 'vant';
Vue.use(Divider).use(Search);

import FindList from './Find/FindList'
import { getFind,FindPeople } from '../api/Find'
export default {
    data(){
        return{
            findData:'',
            personName:''
        }
    },
    components:{
        FindList
    },
    created(){
        let global=this
        document.onkeydown=function(e){
            // console.log(e);
            if(e.keyCode==13){
                global.onSearch()
            }
        }
    },
    mounted(){
       getFind().then(res=>{
            // console.log(res.data);
            this.findData = res.data
        })
    },
    methods:{
        tofind(){
            this.$router.push('/findxy')
        },
        onSearch(){
            FindPeople(this.personName).then(res=>{
                res && this.$router.push(`/findDetail/id=${res._id}`)
            })
        }

    }
}
</script>
<style lang="scss" scoped>
    .content{
        width: 1200px;
        margin: auto;
        .search{
            margin-top: 40px;
            h3{
                font-size: 50px;
                text-align: center;
                font-weight: 100;
                color: #4fc08d;
            }
            .msgBox{
                display: flex;
                .msg{
                    width: 800px;
                    height: 80px;
                    border-radius: 10px;
                    background: rgba(160,160,160,0.5);
                    line-height: 24px;
                    font-size: 13px;
                    padding: 10px 20px 0px;
                }
                .vsearch{
                    width: 400px;
                    display: flex;
                    flex-direction: column;
                    padding-top: 18px;
                }
            }
            
        }

        .myFind{
            display: flex;
            justify-content: center;
            background: #f7f7f7;
            padding: 20px 0;
            margin-top: 40px;
            margin-bottom: 40px;
            h2{
                font-size: 36px;
                margin-right: 50px;
                color: #4fc08d;
            }
            .findBtn{
                width: 160px;
                height: 50px;
                background: #f1861c;
                color: #fff;
                border-radius: 10px;
                line-height: 50px;
                font-size: 27px;
                text-align: center;
                cursor: pointer;
            }
        }
    }
</style>